package jiekou;
public class lianxi {
    public static void main(String[] args) {
        Income[] incomes = new Income[]{
                new Salary(5000),
                new Gaofei(12000),
        };
        System.out.println(TotalTax(incomes));
    }
    public static double TotalTax(Income... incomes) {
        double total = 0;
        for (Income income : incomes) {
            total += income.getTax();
        }
        return total;
    }

}
interface Income{
    double getTax();
}
class Salary implements Income{
    protected  double income;
    public Salary(double income){
        this.income =income;
    }

    @Override
    public double getTax(){
        if (this.income<5000){
            return 0;
        }
        return (income-5000)*0.2;
    }

}
class Gaofei implements Income{
    protected  double income;
    public Gaofei(double income){
        this.income =income;
    }
    @Override
    public double getTax(){
        return this.income*0.3;
    }
}
